#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int arr[10][10];
	int i, j, n = 0, k = 1;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		for (j = i; j < n - i; j++)
		{
			arr[i][j] = k;
			k++;
		}
		for (j = i + 1; j < n - i; j++)
		{
			arr[j][n - 1 - i] = k;
			k++;
		}
		for (j = n - 2 - i; j >= i; j--)
		{
			arr[n - 1 - i][j] = k;
			k++;
		}
		for (j = n - 2 - i; j >= i + 1; j--)
		{
			arr[j][i] = k;
			k++;
		}
	}
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			printf("%4d", arr[i][j]);
		}
		printf("\n");
	}
	return 0;
}